package com.yixia.app.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import com.yixia.app.domain.bo.AppMenuBo;
import com.yixia.app.domain.vo.AppMenuVo;
import com.yixia.app.service.IAppMenuService;
import com.yixia.common.annotation.Log;
import com.yixia.common.core.controller.BaseController;
import com.yixia.common.core.domain.AjaxResult;
import com.yixia.common.core.validate.AddGroup;
import com.yixia.common.core.validate.EditGroup;
import com.yixia.common.enums.BusinessType;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

/**
 * 菜单权限
 *
 * @author ruoyi
 * @date 2023-10-15
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/appMenu")
public class AppMenuController extends BaseController {

    private final IAppMenuService iAppMenuService;

    /**
     * 查询菜单权限列表
     */
    @GetMapping("/list")
    public AjaxResult list() {
        List<AppMenuVo> list = iAppMenuService.queryList(new AppMenuBo());
        return AjaxResult.success(list);
    }

    /**
     * 导出菜单权限列表
     */
    //@SaCheckPermission("system:appMenu:export")
    @Log(title = "菜单权限", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(AppMenuBo bo, HttpServletResponse response) {
        List<AppMenuVo> list = iAppMenuService.queryList(bo);
        //ExcelUtil.exportExcel(list, "菜单权限", AppMenuVo.class, response);
    }

//    /**
//     * 获取菜单权限详细信息
//     *
//     * @param menuId 主键
//     */
//    //@SaCheckPermission("system:appMenu:query")
//    @GetMapping("/{menuId}")
//    public R<AppMenuVo> getInfo(@NotNull(message = "主键不能为空")
//                                     @PathVariable Long menuId) {
//        return R.ok(iAppMenuService.queryById(menuId));
//    }
//
//    /**
//     * 新增菜单权限
//     */
//    //@SaCheckPermission("system:appMenu:add")
//    @Log(title = "菜单权限", businessType = BusinessType.INSERT)
//    //@RepeatSubmit()
//    @PostMapping()
//    public R<Void> add(@Validated(AddGroup.class) @RequestBody AppMenuBo bo) {
//        return toAjax(iAppMenuService.insertByBo(bo));
//    }
//
//    /**
//     * 修改菜单权限
//     */
//    @SaCheckPermission("system:appMenu:edit")
//    @Log(title = "菜单权限", businessType = BusinessType.UPDATE)
//    @RepeatSubmit()
//    @PutMapping()
//    public R<Void> edit(@Validated(EditGroup.class) @RequestBody AppMenuBo bo) {
//        return toAjax(iAppMenuService.updateByBo(bo));
//    }
//
//    /**
//     * 删除菜单权限
//     *
//     * @param menuIds 主键串
//     */
//    @SaCheckPermission("system:appMenu:remove")
//    @Log(title = "菜单权限", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{menuIds}")
//    public R<Void> remove(@NotEmpty(message = "主键不能为空")
//                          @PathVariable Long[] menuIds) {
//        return toAjax(iAppMenuService.deleteWithValidByIds(Arrays.asList(menuIds), true));
//    }
}
